package com.bootx.entity;

import com.fasterxml.jackson.annotation.JsonView;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import org.hibernate.validator.constraints.Length;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * @author black
 */
@Entity
public class Article extends BaseEntity<Long>{

    @JsonView({ViewView.class})
    private String title;

    @Lob
    @Column(columnDefinition = "longtext")
    private String memo;

    private String source;

    private String url;

    private String cover;

    private String author;

    @Lob
    @Column(columnDefinition = "longtext")
    @JsonView({ViewView.class})
    private String content;
    /**
     * 页面标题
     */
    @Length(max = 200)
    private String seoTitle;

    /**
     * 页面关键词
     */
    @Length(max = 2000)
    private String seoKeywords;

    /**
     * 页面描述
     */
    @Length(max = 2000)
    private String seoDescription;

    /**
     * 文章分类
     */
    @ManyToOne(fetch = FetchType.LAZY)
    private ArticleCategory articleCategory;

    /**
     * 文章标签
     */
    @JsonView(BaseView.class)
    @ManyToMany(fetch = FetchType.LAZY)
    @OrderBy("order asc")
    private Set<ArticleTag> articleTags = new HashSet<>();

    private Date publishDate;

    @NotEmpty
    @Column(nullable = false,unique = true,updatable = false)
    private String otherId;

    @Length(max = 100)
    @Column(length = 100)
    private String mediaId;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Set<ArticleTag> getArticleTags() {
        return articleTags;
    }

    public void setArticleTags(Set<ArticleTag> articleTags) {
        this.articleTags = articleTags;
    }

    /**
     * 获取文章分类
     *
     * @return 文章分类
     */
    public ArticleCategory getArticleCategory() {
        return articleCategory;
    }

    /**
     * 设置文章分类
     *
     * @param articleCategory
     *            文章分类
     */
    public void setArticleCategory(ArticleCategory articleCategory) {
        this.articleCategory = articleCategory;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getSeoTitle() {
        return seoTitle;
    }

    public void setSeoTitle(String seoTitle) {
        this.seoTitle = seoTitle;
    }

    public String getSeoKeywords() {
        return seoKeywords;
    }

    public void setSeoKeywords(String seoKeywords) {
        this.seoKeywords = seoKeywords;
    }

    public String getSeoDescription() {
        return seoDescription;
    }

    public void setSeoDescription(String seoDescription) {
        this.seoDescription = seoDescription;
    }

    public Date getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(Date publishDate) {
        this.publishDate = publishDate;
    }

    public String getOtherId() {
        return otherId;
    }

    public void setOtherId(String otherId) {
        this.otherId = otherId;
    }

    public String getMediaId() {
        return mediaId;
    }

    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }
}
